#include "Plant.h"

//ctor dtor
Plant::Plant(){
}
Plant::Plant(PlantType p){
	plantType = p;
	happyMeter = 0;
	switch(plantType){
	case CARROT_PLANT_CODE :
		name = CARROT_PLANT_STRING;
		adultPoint = CARROT_ADULT_POINT;
		harvestPoint = CARROT_HARVEST_POINT;
		ageLeft = CARROT_LIFETIME;
		harvestType = CARROT_HARVEST_TYPE;
		break;
	case CHILLI_PLANT_CODE :
		name = CHILLI_PLANT_STRING;
		adultPoint = CHILLI_ADULT_POINT;
		harvestPoint = CHILLI_HARVEST_POINT;
		ageLeft = CHILLI_LIFETIME;
		harvestType = CHILLI_HARVEST_TYPE;
		break;
	case MELON_PLANT_CODE :
		name = MELON_PLANT_STRING;
		adultPoint = MELON_ADULT_POINT;
		harvestPoint = MELON_HARVEST_POINT;
		ageLeft = MELON_LIFETIME;
		harvestType = MELON_HARVEST_TYPE;
		break;
	case STRAWBERRY_PLANT_CODE :
		name = STRAWBERRY_PLANT_STRING;
		adultPoint = STRAWBERRY_ADULT_POINT;
		harvestPoint = STRAWBERRY_HARVEST_POINT;
		ageLeft = STRAWBERRY_LIFETIME;
		harvestType = STRAWBERRY_HARVEST_TYPE;
		break;
	case TOMATO_PLANT_CODE :
		name = TOMATO_PLANT_STRING;
		adultPoint = TOMATO_ADULT_POINT;
		harvestPoint = TOMATO_HARVEST_POINT;
		ageLeft = TOMATO_LIFETIME;
		harvestType = TOMATO_HARVEST_TYPE;
		break;
	}

}
Plant::~Plant(){
}

//get & set
//naikan happy mater setiap disiram
void Plant::incHappyMeter()
{
	happyMeter++;
}

//reset happy meter kalo dipanen
void Plant::resetHappyMeter()
{
	happyMeter = adultPoint;
}

//naikan harvest point setiap harvest supaya jadi lebih lama panennya
void Plant::incHarvestPoint()
{
	harvestPoint++;
}

//kurangi umur tiap hari
void Plant::decAgeLeft()
{
	ageLeft--;
}

string Plant::getName()
{
	return name;
}
int Plant::getHappyMeter()
{
	return happyMeter;
}
int Plant::getAgeLeft()
{
	return ageLeft;
}
/*
Point Plant::getPosition()
{
	return position;
}
*/
PlantType Plant::getPlantType()
{
	return plantType;
}
HarvestType Plant::getHarvestType(){
	return harvestType;
}
int Plant::getHarvestPoint(){
	return harvestPoint;
}

bool Plant::isAdult(){
	return (happyMeter >= adultPoint);
}

void Plant::initialize(PlantElem plantElem){
    happyMeter = plantElem.HM;
    ageLeft = plantElem.AL;
}
